package com.cnyz.controller;


import com.cnyz.base.PageResponse;
import com.cnyz.base.ResponseResult;
import com.cnyz.service.PaperService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/paper")
@ApiModel(description = "试卷相关接口")
public class PaperController {

    @Autowired
    private PaperService paperService;

    @ApiOperation("从题库根据列表来生成试卷")
    @PostMapping("/generate")
    public ResponseResult generatePaperByList(@RequestBody List<Long> questionIds) {
        paperService.generatePaperByList(questionIds);
        return ResponseResult.success();
    }

    @ApiOperation("根据试卷id获取试卷")
    @GetMapping("/id")
    public ResponseResult getPaperById(

            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam Long id
            ) {
        PageResponse pageResponse = paperService.getPaperByPaperId(pageNum, pageSize, id);
        return ResponseResult.success(pageResponse);

    }


}
